<!DOCTYPE HTML PUBLIC "-//IETF//DTD HTML//EN">
<html>
<head>
<script src="../../resources/js-test.js"></script>
</head>
<body>
<p id="description"></p>
<div id="console"></div>
<script>
  description("Tests that HTMLIFrameElement, HTMLEmbedElement and HTMLObjectElement expose a getSVGDocument accessor");

  window.jsTestIsAsync = true;
  if (window.testRunner)
    testRunner.waitUntilDone();

  var iframe;
  var embed;
  var object;

  function startTest() {
    iframe = document.createElement("iframe");
    iframe.onload = continueTest1;
    iframe.src = "resources/getsvgdocument.svg";
    document.documentElement.appendChild(iframe);
    shouldBeTrue("!!iframe.getSVGDocument");
  }

  var continueTest1 = function() {
    shouldBeEqualToString("iframe.getSVGDocument().toString()", "[object XMLDocument]");
    iframe.parentNode.removeChild(iframe);

    embed = document.createElement("embed");
    embed.onload = continueTest2;
    embed.src = "resources/getsvgdocument.svg";
    document.documentElement.appendChild(embed);
    shouldBeTrue("!!embed.getSVGDocument");
  }

  var continueTest2 = function(event) {
    shouldBeEqualToString("embed.getSVGDocument().toString()", "[object XMLDocument]");
    embed.parentNode.removeChild(embed);

    object = document.createElement("object");
    object.onload = continueTest3;
    object.data = "resources/getsvgdocument.svg";
    document.documentElement.appendChild(object);
    shouldBeTrue("!!object.getSVGDocument");
  }

  function continueTest3() {
    shouldBeEqualToString("object.getSVGDocument().toString()", "[object XMLDocument]");
    object.parentNode.removeChild(object);

    finishJSTest();
  }

  startTest();
</script>
</body>
</html>
